using SalesPages.DomainModel;
using System.ComponentModel.DataAnnotations;
using System.Data.Entity.ModelConfiguration;
namespace SalesPages.EntityFrameworkRepository.Mapping
{
    public class SEOArticleMap : EntityTypeConfiguration<SEOArticle>
    {
        public SEOArticleMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.HeadLine)
                .HasMaxLength(200);

            this.Property(t => t.Link)
                .HasMaxLength(50);

            this.Property(t => t.ImgUrl)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("SEOArticle");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.SEOHubContent_Id).HasColumnName("SEOHubContent_Id");
            this.Property(t => t.HeadLine).HasColumnName("HeadLine");
            this.Property(t => t.Content).HasColumnName("Content");
            this.Property(t => t.Link).HasColumnName("Link");
            this.Property(t => t.ImgUrl).HasColumnName("ImgUrl");
            this.Property(t => t.InsertDate).HasColumnName("InsertDate");
            this.Property(t => t.UpdateDate).HasColumnName("UpdateDate");

            // Relationships
            this.HasRequired(t => t.SEOHubContent)
                .WithMany(t => t.SEOArticles)
                .HasForeignKey(d => d.SEOHubContent_Id);

        }
    }
}
